package com.polaris.live.ui.message.fragment.dialog

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.os.bundleOf
import com.polaris.live.R
import com.polaris.live.common.util.NavigationBarUtils
import com.polaris.live.constant.LiveConst
import com.polaris.live.databinding.FragmentDialogMessageStrangerBinding
import com.polaris.live.ui.message.fragment.MessageStrangerFragment
import com.polaris.live.utils.fragment.attachFragment

/**
 * 直播的陌生人会话列表
 *
 * @author Created by lucas on 2023/10/28 13:44
 * @since 1.0.0
 */
class MessageStrangerDialogFragment : BottomDialogFragment() {

    private val needClickAvatar by lazy { arguments?.getBoolean(LiveConst.Params.NEED_CLICK_AVATAR) ?: true }

    private lateinit var mBinding: FragmentDialogMessageStrangerBinding

    override fun getAnimationStyle(): Int {
        return R.style.RightDialogAnimation
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View {
        return FragmentDialogMessageStrangerBinding.inflate(inflater, container, false).let {
            mBinding = it

            it.root
        }
    }

    private val mFragment by lazy {
        childFragmentManager.attachFragment(R.id.fl_fragment) {
            MessageStrangerFragment().apply {
                arguments = bundleOf(
                    "nestedPage" to true,
                    LiveConst.Params.NEED_CLICK_AVATAR to needClickAvatar,
                )
            }
        }
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        mFragment.setOnLeftClientListener {
            dismiss()
        }

        NavigationBarUtils.setNavigationHeightIfTransparent(mBinding.vBottomLine)
    }
}